<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;

class CreateWechatUsersTable extends Migration {

	/**
	 * Run the migrations.
	 *
	 * @return void
	 */
	public function up()
	{
		Schema::create('wechat_users', function(Blueprint $table)
		{
			$table->increments('id');
			$table->string('openid')->index('wu_oid')->comment('与授权公众号对应的唯一用户ID');
			$table->integer('authorizer_id')->default(0)->comment('对应授权公众号的ID');
			$table->integer('customer_id')->default(0)->comment('无公众号时customer_id');
			$table->string('nickname')->default('')->comment('昵称');
			$table->string('nickname_unicode')->default('')->comment('unicode昵称');
			$table->boolean('subscribe')->default(0)->comment('用户对此公众号的订阅状态 1 / 0');
			$table->string('phone')->nullable()->comment('手机号');
			$table->string('email')->nullable()->comment('邮箱');
			$table->string('name')->nullable()->comment('真实姓名');
			$table->boolean('sex')->default(0)->comment('性别  1男  2女 0未知');
			$table->string('language')->default('zh-CN')->comment('语言');
			$table->string('address')->nullable();
			$table->string('district')->nullable()->comment('区、县');
			$table->string('city')->nullable();
			$table->string('province')->nullable();
			$table->string('country')->nullable();
			$table->string('headimgurl')->nullable()->comment('头像');
			$table->integer('subscribe_time')->nullable()->comment('订阅时间');
			$table->string('subscribe_scene')->nullable()->comment('关注来源');
			$table->string('remark')->nullable()->comment('备注');
			$table->integer('device_id')->unsigned()->default(0)->comment('当前登录的设备，未登录为0');
			$table->decimal('latitude', 20, 10)->nullable()->comment('纬度');
			$table->decimal('longitude', 20, 10)->nullable()->comment('经度');
			$table->timestamps();
			$table->dateTime('born_at')->nullable()->comment('出生日期');
			$table->string('ali_account')->nullable()->comment('测肤用户的支付宝账号');
		});
	}


	/**
	 * Reverse the migrations.
	 *
	 * @return void
	 */
	public function down()
	{
		Schema::drop('wechat_users');
	}

}
